#!/bin/bash
for i in $@; do
	dos2unix $i
	ENCODING="`file -b --mime-encoding $i`"
	if [ "$ENCODING" = "iso-8859-1" ] || [ "$ENCODING" = "us-ascii" ]; then # 注意操作符两边空格
		iconv -f gb2312 -t utf-8 $i > tmp;mv tmp $i 
	    echo "iconv:    converting file $i encoding gb2312 to utf-8..."
	else
		if [ "$ENCODING" != "utf-8" ]; then
			echo "iconv:    unknow file $i encoding type $ENCODING"
			#exit
		fi
	fi
done
